var util = require('../utils/util.js');
var api = require('../config/api.js');
/**
 * 获取提货点
 * @param {} data
 */
async function _getPickupData(data) {
    try{
        // 获取初始数据
        const _this = this;
        const res = await new Promise((resolve, reject)=>{
            wx.getLocation({
                type: "wgs84",
                success:function(res) {
                    resolve(res);
                },
                fail: function(err){
                    reject(err);
                }
            });
        })
        const latitude = res.latitude;
        const longitude = res.longitude;
        const speed = res.speed;
        const accuracy = res.accuracy;

        let params = {
            distance: 0,
            id: 0,
            lat: latitude,
            lon: longitude,
            memberLeaderId: 0,
            storeAddress: "",
            storeImage: "",
            storeName: "",
        };
        params = Object.assign(params, data);
        const result = await util.request(api.store.findAddressInfoList, params)
        return Promise.resolve(result.result);
    }catch(e){
        wx.showToast({
            title: e.message,
            icon: "none",
        });
        return Promise.reject(e.message);
    }
}

module.exports = {
    _getPickupData
}